/***************************init***************/

function queryContractType_contractType(page){
	sys_loading();
	var parm = $('#queryContractTypeForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('contractType-query');
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#contractTypeResultList').html(result);
		}
	});
}

function aidExecuteContractType_contractType(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				queryContractType_contractType();
			} else {
				new $.Zebra_Dialog('操作失败，请刷新页面再次尝试，如果问题依然存在，请联系管理员!', {
				    'buttons':  false,
				    'modal': false,
				    'auto_close': 2000
				});
			}
		}
	});
}

function editContractType_ContractType(code) {
	var parm = {'code':code};
	var url = create_url("contractType-edit");
	$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'500px', open:true});
}

function deleteContractType_contractType(code, name) {
	var url = create_url('contractType-delete');
		$.Zebra_Dialog('要删除《' + name + '》合同类型吗?',{
		'type': 'question',
		'title': '警告' ,
		'buttons':[
	           {caption:'确认',callback:function() {
	        	   aidExecuteContractType_contractType(code, url);
	    		}},
	           {caption:'取消',callback:function(){}
	    	}]
	});
}
/*******************************edit***********************/
function saveContractType_ContractType() {
	var parm = $('#editContractTypeForm').serialize();
	var url = create_url('contractType-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if (result == 'success') {
				sys_load_handle('contractType');
				$.fn.colorbox.close();
				new sys_msg('操作成功');
			}else {
				new sys_msg('操作失败');
			}
		}
	});
}
